<?php
    require_once("dbconnect.php");
    require_once("admin_functions.php");
    require_once("classes/mail.php");

    chk_session();
?>
<?php
    if (!function_exists("GetSQLValueString")) {
        function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") {
            $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

            $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

            switch ($theType) {
                case "text":
                    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
                    break;
                case "long":
                case "int":
                    $theValue = ($theValue != "") ? intval($theValue) : "NULL";
                    break;
                case "double":
                    $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
                    break;
                case "date":
                    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
                    break;
                case "defined":
                    $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
                    break;
            }
            return $theValue;
        }
    }

    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
        $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    }

    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
        $insertSQL = sprintf("INSERT INTO degree (degree_id, degree) VALUES (%s, %s)",
                GetSQLValueString($_POST['degreeid'], "int"),
                GetSQLValueString($_POST['degree'], "text"));


        $Result1 = mysql_query($insertSQL) or die(mysql_error());
    }


    $query_deg = "SELECT degree.degree FROM degree";
    $deg = mysql_query($query_deg) or die(mysql_error());
    $row_deg = mysql_fetch_assoc($deg);
    $totalRows_deg = mysql_num_rows($deg);
?>
<?php require_once('include/header1.php'); ?>
<?php require_once('include/sidebar.php'); ?>
<div id="admin_full_inner_body">


    <table width="100%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#33CCFF">
        <tr>

            <td width="621" valign="top" ><p align="center" class="title"><br>
                    Add Degree </p>
                <form name="form1" method="POST" action="<?php echo $editFormAction; ?>">
                    <table width="80%" border="0" align="center" cellpadding="0" cellspacing="0">
                        <tr>
                            <td>Add Degree : </td>
                            <td><label for="textfield"></label>
                                <input type="text" name="degree" id="degree">
                                <input name="degreeid" type="hidden" id="degreeid"></td>
                        </tr>
                        <tr>
                            <td>&nbsp;</td>
                            <td><label for="Submit"></label>
                                <input type="submit" name="Submit" value="Add Degree" id="Submit"></td>
                        </tr>
                    </table>
                    <input type="hidden" name="MM_insert" value="form1">
                </form>
                <p align="center" class="title">
                    <label for="select">Check Degree! : </label>
                    <select name="select" id="select">
<?php
                            do {
                            ?>
                        <option value="<?php echo $row_deg['degree']?>"><?php echo $row_deg['degree']?></option>
    <?php
                            } while ($row_deg = mysql_fetch_assoc($deg));
                            $rows = mysql_num_rows($deg);
                            if($rows > 0) {
                                mysql_data_seek($deg, 0);
                                $row_deg = mysql_fetch_assoc($deg);
                            }
                        ?>
                    </select>
                </p>
                <p align="center" class="title">How many degrees Avilable </p>
                <p align="center" class="title">&nbsp;</p><br />

            </td>
        </tr>

    </table>
</div>


<?php require_once('include/footer1.php'); ?>
